import os
all_size = 0

def dir_size(dir_name):
    global all_size
    file_list = os.listdir(dir_name)
    print(file_list)
    for file in file_list:
        file_path = os.path.join(dir_name, file)
        print(dir_name)
        if os.path.isfile(file_path):
            size = os.path.getsize(file_path)
            print(size)
            all_size += size
            all_size = all_size + size
            print(file_path)
        else:
            dir_size(file_path)

print('-' * 50)
print('目录文件如下：')
print('-' * 50)
dir_size('/Documents/阶段五')
print('-' * 50)
print('目录总大小：', all_size, '字节')
print('-' * 50)
